#define NUM 9
int a[NUM+1];
main()
{
    int number, i, k, flag, not_finish=1;
    long sum;
    i=1;
    a[1]=1;
    while (not_finish)
    {
        while (not_finish && i<=NUM)
        {
            for (flag=1,k=1; flag && k<i; k++)
              if (a[k]==a[i]) flag=0;
            for (sum=0,k=1; flag && k<=i; k++)
            {
                sum=10*sum+a[k];
                if ( sum%k ) flag=0;
            }
            if (!flag)
            {
                if (a[i]==a[i-1])
                {
                    i--;
                    if (i>1 && a[i]==NUM )
                      a[i]=1;
                    else if (i==1 && a[i]==NUM)
                      not_finish=0;
                    else a[i]++;
                }
                else if (a[i]==NUM) a[i]=1;
                  else a[i]++;
        
            }
            else
              if (++i <= NUM )
                if (a[i-1]==NUM) a[i]=1;
                else a[i]=a[i-1]+1;
        }
        if (not_finish)
        {
            printf ("\nThe progressire divisialble number is: ");
            for (k=1; k<= NUM; k++)
              printf("%d", a[k]);
            if (a[NUM-1]<NUM) a[NUM-1]++;
            else a[NUM-1]=1;
            i=NUM-1;
        }


    }
}